package com.cgy.utils.base.dynamic.handler;

import java.lang.reflect.Method;
import java.text.MessageFormat;

/**
 * @author CH
 */
public class AgencyOptimize implements AgencyHandler {

    private long startTime = -1L;

    @Override
    public void before() {
        startTime = System.currentTimeMillis() / 1000;
    }

    @Override
    public Object[] aroundBefore(Object[] params) {
        return params;
    }

    @Override
    public void after(Method method, Object[] objects) {
        System.out.println(MessageFormat.format("当前方法{1}, 耗时: {0}ms", System.currentTimeMillis() / 1000 - startTime, method.getName()));
    }

    @Override
    public Object aroundAfter(Object o1) {
        return o1;
    }
}
